home *** CD-ROM | disk | FTP | other *** search
Text File | 1996-04-04 | 5.6 KB | 213 lines | [TEXT/KAHL] |
- /***************************************************** IMPLEMENTATION
- DATE: 10/19/93
-
- CLASS: CPPTreeWindow
-
- SUPERCLASS: CPPScrollWindow
-
- This C++ class manages a window which has a visual tree
-
- ********************************************************************/
-
- #include "CPPTreeWindow.h"
- #include <Commands.h>
- #include <MathTools.h>
- #include <CPPDRequest.h>
- #include "MyCommands.h"
- #include "CPPString.h"
- #include <CPPTreeArea.h>
- #include <CPPVisualTree.h>
- #include <CPPVisualTreeNode.h>
-
- /*-----------------------------------------------------------------*/
- /*------------------------ PUBLIC METHODS -------------------------*/
- /*-----------------------------------------------------------------*/
-
- CPPTreeWindow::CPPTreeWindow (CPPWindowManager *theManager, int ResID) :
- CPPWindow (theManager, ResID, FALSE, TRUE, geneva, 9)
- {
- Point topLeft;
-
- theTreeArea = new CPPTreeArea(this, TRUE, TRUE, 10, 10,
- kTopDown, kJustCenter, kRightAngle, 25);
-
- SetMinMaxSize(70, 70, kPageWidth + kSBarWidth,
- kPageHeight + kSBarWidth);
- }
-
- /*-----------------------------------------------------------------*/
-
- CPPTreeWindow::~CPPTreeWindow (void)
- {
- delete theTreeArea;
- }
-
- /*-----------------------------------------------------------------*/
-
- Boolean CPPTreeWindow::Member (char *className)
- {
- if (strcmp(className, CPPTreeWindow::ClassName()) == 0)
- return TRUE;
- else
- return CPPWindow::Member(className);
- }
-
- /*-----------------------------------------------------------------*/
-
- char *CPPTreeWindow::ClassName (void)
- {
- return "CPPTreeWindow";
- }
-
- /*-----------------------------------------------------------------*/
-
- Boolean CPPTreeWindow::DoCommand (short commandID)
- /* the default method sends the command to the target of the */
- /* window. */
- /* SUBCLASS SHOULD OVERRIDE */
- {
- StringPtr Reply = NULL;
- long TLint = 0;
- CPPVisualTreeNode *OperateOn = NULL,
- *TempNode = NULL;
- CPPString *STemp = NULL;
- Boolean result = TRUE;
-
- switch (commandID) {
-
- // kTreeMenu
- case kCmdLength :
- if (DoRequest ("\pEnter the new branch length", "\p25", &Reply))
- {
- StringToNum (Reply, &TLint);
- this->theTreeArea->SetBranchLength ((short)TLint);
- }
- break;
-
- case kCmdAdd :
- if (this->theTreeArea->lastClicked)
- {
- OperateOn = (CPPVisualTreeNode *)this->theTreeArea->lastClicked;
- if (DoRequest ("\pEnter Child's name", "\pChild", &Reply))
- {
- STemp = new CPPString (Reply, TRUE);
- TempNode = new CPPVisualTreeNode (STemp, (CPPTree *)this->theTreeArea,
- TRUE, FALSE);
- OperateOn->AddNode (TempNode);
- }
- }
- break;
-
- case kCmdChangeNode :
- if (this->theTreeArea->lastClicked)
- {
- OperateOn = (CPPVisualTreeNode *)this->theTreeArea->lastClicked;
- if (DoRequest ("\pEnter new name", "\pChild", &Reply))
- {
- STemp = new CPPString (Reply, TRUE);
- OperateOn->SetNodeData (STemp, TRUE);
- }
- }
- break;
-
- case kCmdInsert :
- if (this->theTreeArea->lastClicked)
- {
- OperateOn = (CPPVisualTreeNode *)this->theTreeArea->lastClicked;
- if (DoRequest ("\pEnter new Parent's name", "\pParent", &Reply))
- {
- STemp = new CPPString (Reply, TRUE);
- TempNode = new CPPVisualTreeNode (STemp, (CPPTree *)this->theTreeArea,
- TRUE, FALSE);
- OperateOn->InsertParent (TempNode);
- }
- }
- break;
-
- case kCmdDeleteNode :
- ((CPPVisualTree *)this->theTreeArea)->DoClear();
- break;
-
- case kCmdDeleteFamily :
- if (this->theTreeArea->lastClicked)
- {
- OperateOn = (CPPVisualTreeNode *)this->theTreeArea->lastClicked;
- OperateOn->DeleteFamily (OperateOn);
- }
- break;
-
- // kOrientMenu
- case kCmdTopDown :
- this->theTreeArea->SetOrientation (kTopDown);
- break;
-
- case kCmdBottomUp :
- this->theTreeArea->SetOrientation (kBottomUp);
- break;
-
- case kCmdLeft2Right :
- this->theTreeArea->SetOrientation (kLeft2Right);
- break;
-
- case kCmdRight2Left :
- this->theTreeArea->SetOrientation (kRight2Left);
- break;
-
- // kJustMenu
- case kCmdRightJust :
- this->theTreeArea->SetJustification (kJustRight);
- break;
-
- case kCmdLeftJust :
- this->theTreeArea->SetJustification (kJustLeft);
- break;
-
- case kCmdCenterJust :
- this->theTreeArea->SetJustification (kJustCenter);
- break;
-
- // kJoinMenu
- case kCmdJoinNone :
- this->theTreeArea->SetJoinType (kNoJoin);
- break;
-
- case kCmdJoinAngle :
- this->theTreeArea->SetJoinType (kRightAngle);
- break;
-
- case kCmdJoinPoint :
- this->theTreeArea->SetJoinType (kPointToPoint);
- break;
-
- case kCmdCopy :
- return this->theTreeArea->DoCommand(commandID);
- break;
-
- default :
- return CPPWindow::DoCommand(commandID);
- break;
- }
-
- return result;
- }
-
- /*-----------------------------------------------------------------*/
- /*---------------------- PROTECTED METHODS ------------------------*/
- /*-----------------------------------------------------------------*/
-
- void CPPTreeWindow::DoUserChangeSize (short newWidth, short newHeight)
- /* instance specific handler for resizing the window; use this */
- /* opportunity to change the size of the scrollbars and TE area */
- {
- ((CPPScrollArea *)this->theTreeArea)->Resize (newWidth, newHeight);
- }
-
- /*-----------------------------------------------------------------*/
-
- void CPPTreeWindow::DoUserUpdate (void)
- /* instance specific handler for drawing the window's contents */
- /* SUBCLASS SHOULD OVERRIDE */
- {
- this->theTreeArea->Draw();
- }
-